package com.lft07.status;

/**
 * Function: 		A {@code TestYieldd} 测试礼让线程。<br/>
 * Reason:   		礼让不一定成功，看CPU心情。<br/>
 * Date:            2021-01-27 14:37<br/>
 * <p>
 * Class Name:      TestYieldd<br/>
 * Package Name:    com.lft07.status<br/>
 * @author Laifengting / E-mail:laifengting@foxmail.com
 * @version 1.0.0
 * @since JDK 8
 */
public class TestYield {
	public static void main(String[] args) {
		MyYield myYield = new MyYield();
		new Thread(myYield, "线程1").start();
		new Thread(myYield, "线程2").start();
	}
}

class MyYield implements Runnable {
	@Override
	public void run() {
		System.out.println(Thread.currentThread().getName() + "线程开始执行");
		// 礼让
		Thread.yield();
		System.out.println(Thread.currentThread().getName() + "线程停止执行");
	}
}
